package com.asen.commons.core.listener;

import com.asen.commons.core.base.enums.ActionTypeEnum;
import com.asen.commons.core.base.domain.Core;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.HashMap;
import java.util.Map;

/**
 * 服务上下文环境
 *
 * @author Gary
 * @version 1.0
 * @date 2019-12-04
 */
@Data
@ApiModel("服务上下文环境")
public class ServiceContext<T extends Core> {

    @ApiModelProperty("单据类型")
    private String billType;

    @ApiModelProperty("操作类型")
    private ActionTypeEnum actionType;

    @ApiModelProperty("Service服务对象")
    private Object serviceBean;

    @ApiModelProperty("值对象")
    private T model;

    @ApiModelProperty("结果")
    private Object result;

    @ApiModelProperty("参数")
    private String params;

    @ApiModelProperty("上下文")
    private Map<String, Object> context = new HashMap<>();

    public void put(String key, Object value) {
        context.put(key, value);
    }

    public Object get(String key) {
        return context.get(key);
    }

    public void putAll(Map<String, Object> map) {
        context.putAll(map);
    }

    public Map<String, Object> getAll() {
        return context;
    }

}
